<?php
namespace app\shop\model;

use app\BaseModel;
use think\facade\Db;
class IndexOrderRefund extends BaseModel
{
	//定义表名

	protected $name = 'longbing_card_shop_order_refund';


    /**
     * @param $data
     * @return int|string
     * 添加退款订单
     */
	public function orderAdd($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
	    $res = $this->insert($data);
        $res = $this->getLastInsID();
	    return $res;
    }

    /**
     * 获取订单详情
     */
    public function refundInfo($dis){
        $data = $this
            ->alias('a')
            ->leftJoin('longbing_card_shop_order b' ,'a.order_id = b.id')
            ->where($dis)
            ->field(['a.id,a.order_id,a.status,b.refund_status,b.user_id,b.to_uid, b.price, b.total_price, b.transaction_id, b.out_trade_no'])
            ->find();
        return !empty($data)?$data->toArray():$data;
    }
    /**
     * 修改订单
     */

    public function refundUpdate($dis,$data){
        $data['update_time'] = time();
        $res = Db::name($this->name)->where($dis)->update($data);
        return $res;
    }






}